//
//  LockEventTableViewCell.swift
//  WNLockDemo
//
//  Created by 裴威 on 05/09/2018.
//  Copyright © 2018 wunu. All rights reserved.
//

import UIKit
import Kingfisher

class LockEventTableViewCell: UITableViewCell {
    
    @IBOutlet weak var avatarImageView: UIImageView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var subtitleLabel: UILabel!
    @IBOutlet weak var lockEventTextLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    func loadData(data: WNLockEventModel) {
        
        if let avatarUrl = data.photo {
            avatarImageView.kf.setImage(with: URL(string: avatarUrl))
        }
        nameLabel.text = data.name
        
        let eventStr = data.event! == 0 ? "关锁" : "开锁"
        let stateStr = data.state! == 0 ? "失败" : "成功"
        lockEventTextLabel.text = "\(eventStr)\(stateStr)"
        //        timeLabel.text = data.time
        subtitleLabel.text = data.group! == 0 ? "家庭成员" : "管理员"
//        if let timeStr = data.time {
//            let dateFormmat = DateFormatter()
//            dateFormmat.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" // 2018-03-14T06:35:57.219Z
//            let date = dateFormmat.date(from: timeStr)
//            let translateDateFmt = DateFormatter()
//            translateDateFmt.dateFormat = "MM-dd HH:mm"
//            let showTime = translateDateFmt.string(from: date!)
//            timeLabel.text = showTime
//        }
        
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}
